package com.base.saas.delivery.trace;

import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 王清亮
 * @date 2025/8/2 22:26
 * @description TODO
 */

@Configuration
public class FeignConfig {
    @Bean
    public RequestInterceptor traceFeignInterceptor() {
        return template -> {
            if (TraceContext.getTraceId() != null) {
                template.header(TraceContext.TRACE_ID, TraceContext.getTraceId());
                template.header(TraceContext.SPAN_ID, TraceContext.getSpanId());
            }
        };
    }
}
